package com.spic.business.plan.drill.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.spic.common.log.annotation.Log;
import com.spic.common.log.enums.BusinessType;
import com.spic.common.security.annotation.PreAuthorize;
import com.spic.business.plan.drill.domain.PlanDrillPerformAssess;
import com.spic.business.plan.drill.service.IPlanDrillPerformAssessService;
import com.spic.common.core.web.controller.BaseController;
import com.spic.common.core.web.domain.AjaxResult;
import com.spic.common.core.utils.poi.ExcelUtil;
import com.spic.common.core.web.page.TableDataInfo;

/**
 * 应急预案演练评估Controller
 * 
 * @author renxiang
 * @date 2021-10-31
 */
@RestController
@RequestMapping("/plan/drillAssess")
public class PlanDrillPerformAssessController extends BaseController
{
    @Autowired
    private IPlanDrillPerformAssessService planDrillPerformAssessService;

    /**
     * 查询应急预案演练评估列表
     */
    @PreAuthorize(hasPermi = "business/plan:drillAssess:list")
    @GetMapping("/list")
    public TableDataInfo list(PlanDrillPerformAssess planDrillPerformAssess)
    {
        startPage();
        List<PlanDrillPerformAssess> list = planDrillPerformAssessService.selectPlanDrillPerformAssessList(planDrillPerformAssess);
        return getDataTable(list);
    }

    /**
     * 导出应急预案演练评估列表
     */
    @PreAuthorize(hasPermi = "business/plan:drillAssess:export")
    @Log(title = "应急预案演练评估", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PlanDrillPerformAssess planDrillPerformAssess) throws IOException
    {
        List<PlanDrillPerformAssess> list = planDrillPerformAssessService.selectPlanDrillPerformAssessList(planDrillPerformAssess);
        ExcelUtil<PlanDrillPerformAssess> util = new ExcelUtil<PlanDrillPerformAssess>(PlanDrillPerformAssess.class);
        util.exportExcel(response, list, "应急预案演练评估数据");
    }

    /**
     * 获取应急预案演练评估详细信息
     */
    @PreAuthorize(hasPermi = "business/plan:drillAssess:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(planDrillPerformAssessService.selectPlanDrillPerformAssessById(id));
    }

    /**
     * 新增应急预案演练评估
     */
    @PreAuthorize(hasPermi = "business/plan:drillAssess:add")
    @Log(title = "应急预案演练评估", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PlanDrillPerformAssess planDrillPerformAssess)
    {
        return toAjax(planDrillPerformAssessService.insertPlanDrillPerformAssess(planDrillPerformAssess));
    }

    /**
     * 修改应急预案演练评估
     */
    @PreAuthorize(hasPermi = "business/plan:drillAssess:edit")
    @Log(title = "应急预案演练评估", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PlanDrillPerformAssess planDrillPerformAssess)
    {
        return toAjax(planDrillPerformAssessService.updatePlanDrillPerformAssess(planDrillPerformAssess));
    }

    /**
     * 删除应急预案演练评估
     */
    @PreAuthorize(hasPermi = "business/plan:drillAssess:remove")
    @Log(title = "应急预案演练评估", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(planDrillPerformAssessService.deletePlanDrillPerformAssessByIds(ids));
    }
}
